function ajax(url, param,  async= true,mode = 99) {
    // 校验用户存在
    validateUser();
    $.ajax({
        type: "post",
        dataType: 'json',
        url: url,
        data: JSON.stringify(param),
        contentType: "application/json;charset=UTF-8",
        cache: false,
        async: async,
        success: function (data) {
            switch (mode) {
                case 1:
                    addResult(data);
                    break;
                case 2:
                    delResult(data);
                    break;
                case 3:
                    dropdownServerList(data);
                    break;
                case 4:
                    scanServiceResult(data);
                    break;
                default:
                    simpleResponse(data);
                    break
            }
        }
    });
}
function scanServiceResult(data) {
    if (SUCCESS === data.RSPCD) {
        errorMsg("扫描成功", type.SUCCESS);
        silenceRefresh("list");
    } else {
        errorMsg(data.RSPMSG,type.DANGER)
    }
}
// function addResult(data) {
//     if (SUCCESS === data.RSPCD) {
//         errorMsg("操作成功", type.SUCCESS);
//         clearVal();
//         defaultSet();
//         silenceRefresh("list");
//     } else {
//         errorMsg(data.RSPMSG,type.DANGER)
//     }
// }

function dropdownServerList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    server = data.BODY.LIST;
    // let arr = data.BODY.LIST;
    let append = "";
    // 添加一个空白的公钥
    // append += "<option value=''></option>";
    for (it of server) {
        append += "<option value=\"" + it.ID + "\">" + it.ID + "(" + it.NAME + ")</option>";
    }
    $("#add select[name=server_id]").html(append);
}